@extends('admin.layout')

@section('content')
 <!-- Content Wrapper. Contains page content -->
    <div class="content-wrapper">
        <!-- Content Header (Page header) -->
        <section class="content-header">
            <h1>
                分类管理
                <small>列表</small>
            </h1>
            <ol class="breadcrumb">
                <li><a href="#"><i class="fa fa-dashboard"></i> 分类管理</a></li>
                <li><a href="#">主页</a></li>
                <li class="active">列表</li>
            </ol>
        </section>

        <!-- Main content -->
        <section class="content">
            <div class="row">
                <div class="col-xs-12">
                    <div class="box">      
                        <div class="box-header">
                           
                        <div class="box-body">

                            @if(session('info'))
                            <div class="callout callout-info">
                             <p>{{session('info')}}</p>
                            </div> 
                            @endif
                                 
                                <!--分页开始-->
                            <table id="" class="table table-bordered table-hover">

                                <thead>
                                <tr>
                                    <th>ID</th>
                                    <th>分类名称</th>
                                    <th>操作</th>
                                </tr>
                                </thead>
                                <tbody>
                                @foreach($data as $v)
                                <tr>
                                    <td>{{$v -> id}}</td>
                                    <td class='cname'>{{$v -> name}}</td>
                                   
                                    <td>
                                        <a href="{{ url('admin/cate/edit') }}/{{$v-> id}}">   编辑</a> 
                                        <a class="del" href="" value={{$v -> id}}>删除</a>
                                    </td>
                                </tr>
                                @endforeach
                                </tbody>
                            </table>
                        </div><!-- /.box-body -->
                    </div><!-- /.box -->
                </div><!-- /.col -->
            </div><!-- /.row -->
        </section><!-- /.content -->
    </div><!-- /.content-wrapper -->
    <script type="text/javascript">
       window.onload = function(){
            $(".del").each(function(){
                $(this).click(function(){
                    var id = $(this).attr("value");
                    var it =$(this);
                    if(confirm("确定要删除数据吗？"))
                        {
                            $.ajax({
                                url:"{{ url('admin/cate/delete') }}",
                                data:{id:id},
                                type:"GET",
                                success:function(mes)
                                {
                                    alert(mes);
                                    it.parent().parent().remove();
                                },
                                error:function()
                                {

                                },
                                dataType:"json",

                            });
                            return false;
                        }
                })
            })
        }

    </script>>
 
@endsection